/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.elicitor.core;

import java.io.FileOutputStream;
import java.io.PrintStream;

/**
 *
 * @author dileepa
 */
public class PraatCall {

    String fileLocation;
    
    public PraatCall(String fileLocation) {
        
        this.fileLocation = fileLocation;
    
    }
    
    
    public void createFile(){
        PrintStream out = null;
        
try {
    out = new PrintStream(new FileOutputStream("voiceAtt.praat"));
    out.println("Read from file... "+fileLocation);
    out.println("original= selected(\"Sound\")");
    out.println("orgMinimumSoundPressure=Get minimum... 0 0 Sinc70");
    out.println("orgMaximumSoundPressure=Get maximum... 0 0 Sinc70");
    out.println("orgMean=Get mean... 0 0 0");
    out.println("orgRootMeanSquare=Get root-mean-square... 0 0");
    out.println("orgStd=Get standard deviation... 0 0 0");
    out.println("orgEnergy=Get energy... 0 0");
    out.println("orgPower=Get power... 0 0");
    out.println("orgEnergyInAir=Get energy in air");
    out.println("orgPowerInAir=Get power in air");
    out.println("orgIntensity=Get intensity (dB)");
    out.println("pitch=To Pitch... 0 5 600");
    out.println("pitchMinimum=Get minimum... 0 0 Hertz Parabolic");
    out.println("pitchMaximum=Get maximum... 0 0 Hertz Parabolic");
    out.println("pitchQ1=Get quantile... 0 0 0.25 Hertz");
    out.println("pitchQ2=Get quantile... 0 0 0.5 Hertz");
    out.println("pitchQ3=Get quantile... 0 0 0.75 Hertz");
    out.println("pitchMean=Get mean... 0 0 Hertz");
    out.println("pitchStd=Get standard deviation... 0 0 Hertz");
    out.println("echo \'orgMinimumSoundPressure\',\'orgMaximumSoundPressure\',\'orgMean\',\'orgRootMeanSquare\',\'orgStd\',\'orgEnergy\',\'orgPower\',\'orgEnergyInAir\',\'orgPowerInAir\',\'orgIntensity\',\'pitchMinimum\',\'pitchMaximum\',\'pitchQ1\',\'pitchQ2\',\'pitchQ3\',\'pitchMean\',\'pitchStd\'");
}catch(Exception e){
    System.err.println("Errroer "+e.getMessage());
}
finally {
    if (out != null) out.close();
}

    }
    
   public void sendPraat(){
              Runtime run = Runtime.getRuntime();
        try {
            String[] sendpraatCom = new String[3];
            sendpraatCom[0] = "./sendpraat";
            sendpraatCom[1] = "praat";
            sendpraatCom[2] = "execute " + "/home/dileepa/Documents/elicitor/voiceAtt.praat";
            run.exec(sendpraatCom);
        } catch (Exception ex) {
            System.err.println("Error... "+ex.getMessage());
        }
   } 
    
    
    
    
}
